package com.hhu.wangzb.server.config;

import com.hhu.wangzb.common.entity.ProjectDetailEntity;
import com.hhu.wangzb.common.entity.index.EntityIndexTree;
import com.hhu.wangzb.common.entity.index.IndexTreeMapper;
import com.hhu.wangzb.server.dao.ProjectDetailDao;
import com.hhu.wangzb.server.service.ProjectDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

//@Configuration
public class SystemConfig {

    @Autowired(required = false)
    ProjectDetailDao projectDetailDao;

    @Bean
    public IndexTreeMapper indexTreeMapper() {
        ProjectDetailEntity projectDetailEntity = projectDetailDao.selectById(1);

        IndexTreeMapper mapper = new IndexTreeMapper();

        EntityIndexTree tree = new EntityIndexTree();

        tree.addNode(ProjectDetailEntity.class, projectDetailEntity.getId(), -1, projectDetailEntity.getPvaId(), projectDetailEntity.getRgId());

        mapper.put(projectDetailEntity.getId(), tree);

        return mapper;
    }
}
